using System;
using System.Collections.Generic;
using System.Text;

namespace FreeSMS.Configuration.Attributes
{
    [AttributeUsage(AttributeTargets.Property)]
    public class PropertyOrderAttribute : Attribute
    {
      private int _order;
      public PropertyOrderAttribute(int order)
      {
        _order = order;
      }

      public int Order
      {
        get { return _order; }
      }
    }

    public class PropertyOrderPair : IComparable
    {
      private int _order;
      private string _name;

      public string Name
      {
        get { return _name; }
      }

      public PropertyOrderPair(string name, int order)
      {
        _order = order;
        _name = name;
      }

      public int CompareTo(object obj)
      {
        int otherOrder = ((PropertyOrderPair)obj)._order;

        if (otherOrder == _order)
        {
          string otherName = ((PropertyOrderPair)obj)._name;
          return string.Compare(_name, otherName);
        }
        else if (otherOrder > _order)
          return -1;

        return 1;
      }
    }
}
